<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gabungan extends MX_Controller {
    
  function __construct() {
//    $this->load->library('manimage');
    $this->load->model('frm/mfrm');
    $this->menu = $this->cek();
  }
  
  function neraca($id_keuangan_yayasan_journal){
    
    $detail_journal = $this->global_models->get("keuangan_yayasan_journal", array("id_keuangan_yayasan_journal" => $id_keuangan_yayasan_journal));
    
    $id_frm_journal = $this->global_models->get_field("frm_journal", "id_frm_journal", array("status" => 2, "month" => $detail_journal[0]->month, "year" => $detail_journal[0]->year));
    
    $neraca_yayasan = $this->global_models->get_query("
      SELECT A.title, A.nomor, B.*, A.pos, A.labarugi, A.id_frm_account
      FROM frm_account AS A
      LEFT JOIN keuangan_yayasan_journal_bukubesar AS B ON (B.id_frm_account = A.id_frm_account AND B.id_keuangan_yayasan_journal = {$id_keuangan_yayasan_journal})
      ORDER BY A.nomor ASC
      ");
      
    $neraca_kampus = $this->global_models->get_query("
      SELECT A.title, A.nomor, B.*, A.pos, A.labarugi, A.id_frm_account
      FROM frm_account AS A
      LEFT JOIN frm_journal_bukubesar AS B ON (B.id_frm_account = A.id_frm_account AND B.id_frm_journal = {$id_frm_journal})
      ORDER BY A.nomor ASC
      ");
      
    $neraca_penyesuaian = $this->global_models->get_query("
      SELECT A.title, A.nomor, B.*, A.pos
      FROM frm_account AS A
      LEFT JOIN keuangan_yayasan_neraca_penyesuaian AS B ON (B.id_frm_account = A.id_frm_account AND B.id_keuangan_yayasan_journal = {$id_keuangan_yayasan_journal})
      ORDER BY A.nomor ASC
      ");
    
//    $pajak = $this->global_models->get_query("
//      SELECT A.title, A.nomor, B.*, A.pos
//      FROM frm_account_pajak AS A
//      LEFT JOIN keuangan_yayasan_neraca_pajak AS B ON (B.id_frm_account_pajak = A.id_frm_account_pajak AND B.id_keuangan_yayasan_journal = {$id_keuangan_yayasan_journal})
//      ORDER BY A.nomor ASC
//      ");
      
    $neraca = array(
        "yayasan"         => $neraca_yayasan,
        "kampus"          => $neraca_kampus,
        "pajak"           => $pajak,
    );
    
    $this->template->build("gabungan/neraca",
      array(
            'url'         => base_url()."themes/srabon2/",
            'theme2nd'    => 'srabon2',
            'menu'        => 'keuangan-yayasan/journal',
            'title'       => lang("keuangan_yayasan_neraca_gabungan"),
            'id_keuangan_yayasan_journal' => $id_keuangan_yayasan_journal,
            'neraca'      => $neraca
          ));
    $this->template
      ->set_layout('default')
      ->build("gabungan/neraca");
  }
  
  public function journal_penyesuaian($id_keuangan_yayasan_journal){
    
    $total = $this->global_models->get_query("
      SELECT count(A.id_keuangan_yayasan_journal_log_penyesuaian) AS jumlah
      FROM keuangan_yayasan_journal_log_penyesuaian AS A
      WHERE A.id_keuangan_yayasan_journal = {$id_keuangan_yayasan_journal}
      ");
      
    $this->template->build("journal-log-penyesuaian",
      array(
            'url'         => base_url()."themes/".DEFAULTTHEMES."/",
            'menu'        => 'keuangan-yayasan/journal',
            'title'       => lang("frm_journal_transaksi_penyesuaian")." ".$this->global_models->get_field("keuangan_yayasan_journal", "title", array("id_keuangan_yayasan_journal" => $id_keuangan_yayasan_journal)),
            'total'       => $total[0]->jumlah,
            'id_keuangan_yayasan_journal' => $id_keuangan_yayasan_journal
          ));
    $this->template
      ->set_layout('default')
      ->build("journal-log-penyesuaian");
	}
  
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */